/*
 * @Author: your name
 * @Date: 2022-04-10 17:41:26
 * @LastEditTime: 2022-04-13 14:45:05
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \drivingTow\src\score\score.controller.ts
 */
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import { ScoreService } from './score.service';
import { AverageDto, CreateScoreDto } from './dto/create-score.dto';
import { UpdateScoreDto } from './dto/update-score.dto';
import { ApiBearerAuth, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { RolesGuard } from 'src/auth/role.guard';
import { SelectTraineeDto } from 'src/trainees/dto/update-trainee.dto';

@ApiTags('学员评分记录表')
@Controller('score')
export class ScoreController {
  constructor(private readonly scoreService: ScoreService) {}
  @ApiOperation({ summary: '创建学员评分记录' })
  @ApiBearerAuth()
  @Post('createScore')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async createScore(@Body() post:CreateScoreDto){
    return await this.scoreService.createScore(post)
  }

  @ApiOperation({ summary: '管理员查看所有评分记录' })
  @ApiBearerAuth()
  @Post('getAllScore')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async getAllScore(@Body() post:SelectTraineeDto){
    return await this.scoreService.getAllScore(post)
  }

  @ApiOperation({ summary: '获取教练员的平均评分' })
  @ApiBearerAuth()
  @Post('getAverageScore')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async getAverageScore(@Body() post:AverageDto){
    return await this.scoreService.getAverageScore(post)
  }

  @ApiOperation({ summary: '管理员删除评价' })
  @ApiParam({name:'id',description:'id'})
  @ApiBearerAuth()
  @Post('deleteScore')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async deleteScore(@Param('id') id){
    return await this.scoreService.deleteScore(id)
  }

  @ApiOperation({ summary: '学员评价教练员' })
  @ApiBearerAuth()
  @Post('makeScore')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async makeScore(@Body() post:UpdateScoreDto){
    return await this.scoreService.makeScore(post)
  }
}
